package Controllers;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import Entities.InitiateSaleEntity;
import Entities.MarketingDistributionsEntity;
import GUI.InitiateSaleGUI;
import GUI.ManageLivArTabGUI;
import GUI.MarketingDistributionsGUI;
import GUI.MarketingEmployeeGUI;
import GUI.MarketingManagerGUI;
import GUI.ReportsGUI;

/**
 * The Class MarketingManagerController.
 * Controller for marketing manager activities.
 */
public class MarketingManagerController {
	
	/** The marketing manager gui. */
	private MarketingManagerGUI marketingManagerGui;

	/**
	 * Instantiates a new marketing manager controller.
	 *
	 * @param marketingManagerGui the marketing manager gui
	 */
	public MarketingManagerController(MarketingManagerGUI marketingManagerGui) {
		this.marketingManagerGui = marketingManagerGui;
		this.marketingManagerGui.addManageLatActionListener(new ManageLatListener());
		this.marketingManagerGui.addManageProdDistActionListener(new ManageProdDistListener());
		this.marketingManagerGui.addInitiatSaleActionListener(new InitSaleListener());
		this.marketingManagerGui.addProduceRepActionListener(new ProdRepListener());
		this.marketingManagerGui.addMarketingEmployeeOptionsActionListener(new MarketingEmployeeOptionsListener());
	}
	
	
	/**
	 * Gets the marketing manager gui.
	 *
	 * @return the marketing manager gui
	 */
	public MarketingManagerGUI getMarketingManagerGui() {
		return marketingManagerGui;
	}


	/**
	 * The listener interface for receiving manageLat events.
	 * The class that is interested in processing a manageLat
	 * event implements this interface, and the object created
	 * with that class is registered with a component using the
	 * component's <code>addManageLatListener<code> method. When
	 * the manageLat event occurs, that object's appropriate
	 * method is invoked.
	 *
	 * @see ManageLatEvent
	 */
	class ManageLatListener implements ActionListener
	{

		/* (non-Javadoc)
		 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
		 */
		@Override
		public void actionPerformed(ActionEvent e) {
			ManageLivArTabGUI manageLivArTabGUI = new ManageLivArTabGUI();
			new ManageLivArTabController(manageLivArTabGUI).setPrev(MarketingManagerController.this);
			LoginController.mainWindow.setContentPane(manageLivArTabGUI);
			
		}
		
	}
	
	/**
	 * The listener interface for receiving manageProdDist events.
	 * The class that is interested in processing a manageProdDist
	 * event implements this interface, and the object created
	 * with that class is registered with a component using the
	 * component's <code>addManageProdDistListener<code> method. When
	 * the manageProdDist event occurs, that object's appropriate
	 * method is invoked.
	 *
	 * @see ManageProdDistEvent
	 */
	class ManageProdDistListener implements ActionListener
	{

		/* (non-Javadoc)
		 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
		 */
		@Override
		public void actionPerformed(ActionEvent e) {
			MarketingDistributionsGUI marketingDistributionsGUI = new MarketingDistributionsGUI();
			new MarketingDistributionsController(marketingDistributionsGUI,new MarketingDistributionsEntity()).setPrev(MarketingManagerController.this);
			LoginController.mainWindow.setContentPane(marketingDistributionsGUI);
		}
		
	}
	
	/**
	 * The listener interface for receiving initSale events.
	 * The class that is interested in processing a initSale
	 * event implements this interface, and the object created
	 * with that class is registered with a component using the
	 * component's <code>addInitSaleListener<code> method. When
	 * the initSale event occurs, that object's appropriate
	 * method is invoked.
	 *
	 * @see InitSaleEvent
	 */
	class InitSaleListener implements ActionListener
	{

		/* (non-Javadoc)
		 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
		 */
		@Override
		public void actionPerformed(ActionEvent e) {
			InitiateSaleGUI initiateSaleGUI = new InitiateSaleGUI();
			new InitiateSaleController(new InitiateSaleEntity(),initiateSaleGUI).setPrev(MarketingManagerController.this);
			LoginController.mainWindow.setContentPane(initiateSaleGUI);
			
		}
		
	}
	
	/**
	 * The listener interface for receiving prodRep events.
	 * The class that is interested in processing a prodRep
	 * event implements this interface, and the object created
	 * with that class is registered with a component using the
	 * component's <code>addProdRepListener<code> method. When
	 * the prodRep event occurs, that object's appropriate
	 * method is invoked.
	 *
	 * @see ProdRepEvent
	 */
	class ProdRepListener implements ActionListener
	{

		/* (non-Javadoc)
		 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
		 */
		@Override
		public void actionPerformed(ActionEvent e) {
			ReportsGUI ReportsGUI = new ReportsGUI();
			new ReportsController(ReportsGUI).setPrev(MarketingManagerController.this);
			LoginController.mainWindow.setContentPane(ReportsGUI);
			
			
		}
		
	}
	
	/**
	 * The listener interface for receiving marketingEmployeeOptions events.
	 * The class that is interested in processing a marketingEmployeeOptions
	 * event implements this interface, and the object created
	 * with that class is registered with a component using the
	 * component's <code>addMarketingEmployeeOptionsListener<code> method. When
	 * the marketingEmployeeOptions event occurs, that object's appropriate
	 * method is invoked.
	 *
	 * @see MarketingEmployeeOptionsEvent
	 */
	class MarketingEmployeeOptionsListener implements ActionListener
	{

		/* (non-Javadoc)
		 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
		 */
		@Override
		public void actionPerformed(ActionEvent e) {
			MarketingEmployeeGUI mEmployeeGUI=new MarketingEmployeeGUI();
			new MarketingEmployeeController(mEmployeeGUI,1).setPrev(MarketingManagerController.this);
			LoginController.mainWindow.setContentPane(mEmployeeGUI);
			LoginController.mainWindow.setTitle("Marketing employee");
		}
		
	}
	
}
